/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Acceso;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author alb3rto
 */
public class cambiarPasswordForm extends org.apache.struts.action.ActionForm {

    private String usuario;
    private String pwdActual;
    private String pwdNueva;
    private String pwdNueva2;

    public String getUsuario() {
        return usuario;
    }

    public void setUsuario(String usuario) {
        this.usuario = usuario;
    }
    
    public String getPwdActual() {
        return pwdActual;
    }

    public void setPwdActual(String pwdActual) {
        this.pwdActual = pwdActual;
    }

    public String getPwdNueva() {
        return pwdNueva;
    }

    public void setPwdNueva(String pwdNueva) {
        this.pwdNueva = pwdNueva;
    }

    public String getPwdNueva2() {
        return pwdNueva2;
    }

    public void setPwdNueva2(String pwdNueva2) {
        this.pwdNueva2 = pwdNueva2;
    }


    /**
     *
     */
    public cambiarPasswordForm() {
        super();
        // TODO Auto-generated constructor stub
    }

    /**
     * This is the action called from the Struts framework.
     * @param mapping The ActionMapping used to select this instance.
     * @param request The HTTP Request we are processing.
     * @return
     */
    @Override
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        if (getPwdActual() == null || getPwdActual().equals("")) {
            errors.add("contraseñaRequerida", new ActionMessage("error.contraseñaRequerida"));
        } else if (FormatUtility.validatePattern(pwdNueva, 5)) {
            errors.add("contraseñaInvalida", new ActionMessage("error.contraseñaInvalida"));
        }
        if (getPwdNueva() == null || getPwdNueva().equals("")) {
            errors.add("contraseñaRequerida", new ActionMessage("error.contraseñaRequerida"));
        } else if (FormatUtility.validatePattern(pwdNueva, 5)) {
            errors.add("contraseñaInvalida", new ActionMessage("error.contraseñaInvalida"));
        }
        if (getPwdNueva() == null || getPwdNueva().equals("")) {
            errors.add("contraseñaRequerida", new ActionMessage("error.contraseñaRequerida"));
        } else if (!getPwdNueva().equals(getPwdNueva2())) {
            errors.add("contraseñasNoCoinciden", new ActionMessage("error.contraseñasNoCoinciden"));
        }
        return errors;
    }
}
